import javax.swing.JPanel;

import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.Component;
import javax.swing.Box;
import javax.swing.JTextArea;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JComboBox;
import java.awt.Font;
import javax.swing.UIManager;
import java.awt.Color;
import java.awt.Label;
import java.sql.Date;
import javax.swing.JCheckBox;
import java.awt.Checkbox;

public class AddUserGUI extends JPanel {
    /**
	 * 
	 */
    private static final long serialVersionUID = 1L;
    User newUser;
    int location;

    private JTextField textField;
    private JTextField textField_1;
    private JTextField textField_2;
    private JTextField textField_3;
    private JTextField textField_4;
    private JTextField textField_6;
    private JTextField textField_7;
    private JTextField textField_8;
    private JTextField textField_9;
    private JTextField textField_10;
    private JTextField textField_5;
    private JTextField textField_11;

    public AddUserGUI() {

        newUser = new User();

        setBackground(Color.LIGHT_GRAY);
        setForeground(Color.LIGHT_GRAY);
        setLayout(null);

        final Checkbox checkbox = new Checkbox("New check box");
        checkbox.setBounds(587, 276, 95, 22);
        add(checkbox);

        final Checkbox checkbox_1 = new Checkbox("New check box");
        checkbox_1.setBounds(587, 297, 95, 22);
        add(checkbox_1);

        final Checkbox checkbox_2 = new Checkbox("New check box");
        checkbox_2.setBounds(587, 324, 95, 22);
        add(checkbox_2);

        final Checkbox checkbox_3 = new Checkbox("New check box");
        checkbox_3.setBounds(587, 352, 95, 22);
        add(checkbox_3);

        JLabel lblName = new JLabel("Name");
        lblName.setFont(new Font("Lucida Grande", Font.BOLD, 13));
        lblName.setBounds(23, 64, 45, 14);
        add(lblName);

        textField = new JTextField();
        textField.setBounds(110, 58, 167, 20);
        add(textField);
        textField.setColumns(10);

        JLabel lblAddress = new JLabel("Address");
        lblAddress.setBounds(23, 166, 69, 14);
        add(lblAddress);

        textField_1 = new JTextField();
        textField_1.setBounds(110, 160, 167, 20);
        add(textField_1);
        textField_1.setColumns(10);

        JLabel lblNewLabel = new JLabel("Phone");
        lblNewLabel.setBounds(23, 112, 69, 14);
        add(lblNewLabel);

        textField_2 = new JTextField();
        textField_2.setBounds(110, 106, 125, 20);
        add(textField_2);
        textField_2.setColumns(10);

        JLabel lblCell = new JLabel("Cell");
        lblCell.setBounds(267, 112, 58, 14);
        add(lblCell);

        textField_3 = new JTextField();
        textField_3.setBounds(302, 106, 125, 20);
        add(textField_3);
        textField_3.setColumns(10);

        JLabel lblEmail = new JLabel("Email");
        lblEmail.setBounds(23, 208, 105, 14);
        add(lblEmail);

        textField_4 = new JTextField();
        textField_4.setBounds(110, 202, 167, 20);
        add(textField_4);
        textField_4.setColumns(10);

        JLabel lblNewLabel_1 = new JLabel("Gender");
        lblNewLabel_1.setBounds(23, 284, 63, 14);
        add(lblNewLabel_1);

        JLabel lblNewLabel_2 = new JLabel("Pharmacy");
        lblNewLabel_2.setBounds(23, 324, 77, 14);
        add(lblNewLabel_2);

        textField_6 = new JTextField();
        textField_6.setBounds(110, 318, 173, 20);
        add(textField_6);
        textField_6.setColumns(10);

        JLabel lblInsurance = new JLabel("Birth Date");
        lblInsurance.setBounds(23, 413, 95, 14);
        add(lblInsurance);

        textField_7 = new JTextField();
        textField_7.setBounds(302, 321, 175, 92);
        add(textField_7);
        textField_7.setColumns(10);

        JLabel lblAllergies = new JLabel("Allergies");
        lblAllergies.setBounds(321, 297, 95, 14);
        add(lblAllergies);

        JButton btnCancel = new JButton("Cancel");
        btnCancel.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                location = -1;
            }
        });
        btnCancel.setBounds(106, 438, 89, 23);
        add(btnCancel);

        JButton btnNewButton = new JButton("Okay");
        btnNewButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                location = 14;

                newUser.setAddress(textField_1.getText());
                newUser.setAllergies(textField_7.getText());
                newUser.setInsurance(textField_5.getText());
                newUser.setBirthDate(Date.valueOf(textField_11.getText()));
                newUser.setSSN(Integer.parseInt(textField_8.getText()));
                newUser.setEmail(textField_4.getText());
                newUser.setCellPhone(textField_3.getText());
                newUser.setPhone(textField_2.getText());
                newUser.setUserName(textField_10.getText());
                newUser.setPassword(textField_9.getText());
                // boolean b = chckbxNurse.getState();
                boolean[] roles;
                roles = new boolean[4];

                roles[0] = checkbox.getState();
                roles[1] = checkbox_1.getState();
                roles[2] = checkbox_2.getState();
                roles[3] = checkbox_3.getState();

                newUser.setRoles(roles);

                newUser.setPharmacy(textField_6.getText());
                newUser.setName(textField.getText());

            }
        });
        btnNewButton.setBounds(23, 438, 85, 23);
        add(btnNewButton);

        JComboBox comboBox_1 = new JComboBox();
        comboBox_1.setBounds(610, 188, 87, 20);
        add(comboBox_1);

        JLabel lblSocialSecurity = new JLabel("SSN");
        lblSocialSecurity.setBounds(23, 241, 45, 20);
        add(lblSocialSecurity);

        textField_8 = new JTextField();
        textField_8.setBounds(109, 240, 86, 20);
        add(textField_8);
        textField_8.setColumns(10);

        JLabel lblRole = new JLabel("Role");
        lblRole.setBounds(527, 244, 46, 14);
        add(lblRole);

        JLabel lblNewLabel_3 = new JLabel("Suspension");
        lblNewLabel_3.setBounds(527, 194, 77, 14);
        add(lblNewLabel_3);

        JLabel lblPassword = new JLabel("Password");
        lblPassword.setBounds(527, 92, 88, 20);
        add(lblPassword);

        textField_9 = new JTextField();
        textField_9.setBounds(610, 92, 131, 20);
        add(textField_9);
        textField_9.setColumns(10);

        JLabel lblUsername = new JLabel("Username");
        lblUsername.setBounds(527, 64, 77, 14);
        add(lblUsername);

        textField_10 = new JTextField();
        textField_10.setBounds(610, 58, 131, 20);
        add(textField_10);
        textField_10.setColumns(10);

        JLabel lblAddANew = new JLabel("Add a New User");
        lblAddANew.setForeground(Color.BLACK);
        lblAddANew.setFont(new Font("Arial", Font.BOLD, 20));
        lblAddANew.setBounds(12, 8, 225, 30);
        add(lblAddANew);

        JLabel lblLastFirstMi = new JLabel("Last, First MI");
        lblLastFirstMi.setForeground(Color.DARK_GRAY);
        lblLastFirstMi.setFont(new Font("Lucida Grande", Font.PLAIN, 10));
        lblLastFirstMi.setBounds(120, 84, 115, 16);
        add(lblLastFirstMi);

        JLabel label = new JLabel("##########");
        label.setFont(new Font("Lucida Grande", Font.PLAIN, 8));
        label.setBounds(120, 132, 89, 16);
        add(label);

        JLabel label_1 = new JLabel("##########");
        label_1.setFont(new Font("Lucida Grande", Font.PLAIN, 8));
        label_1.setBounds(312, 132, 89, 16);
        add(label_1);

        JComboBox comboBox_2 = new JComboBox();
        comboBox_2.setBounds(109, 278, 86, 20);
        add(comboBox_2);

        JLabel lblCharacters = new JLabel("6-12 Characters");
        lblCharacters.setFont(new Font("Lucida Grande", Font.PLAIN, 10));
        lblCharacters.setBounds(626, 112, 115, 16);
        add(lblCharacters);

        textField_5 = new JTextField();
        textField_5.setColumns(10);
        textField_5.setBounds(110, 369, 175, 20);
        add(textField_5);

        JLabel label_2 = new JLabel("Insurance");
        label_2.setBounds(23, 372, 95, 14);
        add(label_2);

        textField_11 = new JTextField();
        textField_11.setColumns(10);
        textField_11.setBounds(117, 410, 175, 20);
        add(textField_11);

        JLabel lblDoctor = new JLabel("Doctor");
        lblDoctor.setBounds(535, 324, 46, 14);
        add(lblDoctor);

        JLabel lblNurse = new JLabel("Nurse");
        lblNurse.setBounds(535, 304, 46, 14);
        add(lblNurse);

        JLabel lblAdmin = new JLabel("Admin");
        lblAdmin.setBounds(535, 352, 46, 14);
        add(lblAdmin);

        JLabel lblPatient = new JLabel("Patient");
        lblPatient.setBounds(535, 276, 46, 14);
        add(lblPatient);

    }

    public int getLoc() {
        return location;
    }

    public void setLoc(int i) {
        location = i;
    }

    public User getUser() {
        return newUser;
    }
}
